<template>
<div>
  <h1 @click="getAdmin">修改密码</h1>
  <el-form :label-position="admin" label-width="80px" :model="admin">
    <el-form-item label="账号">
      <el-input v-model="admin.name" disabled></el-input>
    </el-form-item>
    <el-form-item label="重置密码">
      <el-input v-model="admin.pwd"></el-input>
    </el-form-item>
    <el-button type="danger" @click="reset">重置</el-button>
  </el-form>
</div>
</template>

<script>
export default {
  name: "RestePwd",
  data(){
    return {
      admin: {
        id: '',
        name: '',
        pwd: ''
      }

    }
  },
  created() {
    this.getAdmin()
  },
  methods: {
    reset(){
      this.$axios({
        method: 'post',
        url: '/admin/resetPwd',
        data: this.admin
      }).then(res=>{
        alert(res.data.message)
        localStorage.setItem('adtoken','')
        this.$router.push('/login')
      })
    },
    getAdmin(){
      this.$axios({
        method: 'get',
        url: '/admin/getAdmin'
      }).then(res=>{
        this.admin = res.data.data.data
      })
    }
  }
}
</script>

<style scoped>

</style>
